import { actionPermissions } from "../utils/permission";
import { getUserRole } from '../api/user';

export const permissionDirective = {
  async mounted(el, binding) {
    const { value } = binding;
    const userRole = await getUserRole();
    
    if (userRole === null || !actionPermissions[value]?.includes(userRole)) {
      el.style.display = 'none';
    }
  }
}